﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FrameWork.Source.Object_Classes;
using Microsoft.Xna.Framework;

namespace Boomer.Source.MapItem
{
    class MapItemManager
    {

        private static MapItemManager manager = null;

        private List<CMapItem> listItem;


        MapItemManager()
        {
            listItem = new List<CMapItem>();
        }


        public static MapItemManager getInstance()
        {
            if (manager == null)
                manager = new MapItemManager();

            return manager;
        }

        public void addItem(CMapItem item)
        {
            listItem.Add(item);
        }

        public void collision(ref CObject pObj)
        {
            int count = listItem.Count;

            for (int i = 0; i < count; ++i)
            {
                if( listItem[i].m_isColliable && listItem[i].m_isAlive )
                    listItem[i].Collision(ref pObj);
            }
        }

        public void update(float deltaTime)
        {
            int count = listItem.Count;

            for (int i = 0; i < count; ++i)
            {
                if (listItem[i].m_isAlive)
                    listItem[i].update(deltaTime);
            }
        }

        public void draw()
        {
            int count = listItem.Count;

            for (int i = 0; i < count; ++i)
            {
                if( listItem[i].m_isAlive )
                    listItem[i].draw();
            }
        }

        public void clear()
        {
            listItem.Clear();
        }
    }
}
